<template>
           
    <div class="crumbs">
                   
        <el-breadcrumb separator="/">
                            <h3 style="color #DDDDDD">当前位置:考试任务管理/考试任务设置</h3>
                       
        </el-breadcrumb>
               
    </div>
    <!-- 下拉列表 -->

    <el-tooltip class="item" effect="dark" content="请选择班级" hide-after="2000" v-model="tooltip" placement="top">

        <el-select v-model="valueId" placeholder="选择班级" style="width: 150px; margin-left: 20px">
            <el-option
                    v-for="item in options"
                    :key="item.classname"
                    :label="item.classname"
                    :value="item.pkId"
            >
            </el-option>
        </el-select>
    </el-tooltip>


    <h5>操作提示:请选择班级，然后选择班级对应要考试的课程</h5>
    <el-table
            :data="tableData"
            style="width: 100%">
        <el-table-column
                prop="curriculumId"
                label="课程编号"
                width="250">
        </el-table-column>
        <el-table-column
                prop="curriculumname"
                label="课程名称"
                width="250">
        </el-table-column>
        <el-table-column
                prop="isopen"
                label="是否开卷"
                width="250"
        >
        </el-table-column>
        <el-table-column
                prop="theteacher"
                label="任课教师"
                width="250"
        >
        </el-table-column>
        <el-table-column
                prop="operation"
                label="操作"
                width="250">
            <template #default="scope">

                <el-button type="primary" @click="xaunding(scope.row)">选定</el-button>
            </template>


        </el-table-column>
    </el-table>
    <el-pagination
            background
            @current-change="page"
            current-page.sync="5"
            :page-size="currentPage.limit"
            layout="total, prev, pager, next"
            :total="currentPage.current">
    </el-pagination>

</template>
<script>
    import {kaoshitaskSetupList} from '../api/index.js'
    import {classpostmethod, xaunding} from "../api/index";

    export default {
        created() {
            this.getdata();
        },
        methods: {
            getdata() {
                kaoshitaskSetupList(this.currentPage).then(Object => {
                    this.tableData = Object.records[0];
                    this.currentPage.current = Object.rowCount;

                })

                classpostmethod({
                    page: 1,
                    total: 20,
                    count: 50,
                    current: 0,
                    limit: 100
                },).then(Object => {
                    this.options = Object.records[0];
                    console.log(Object);

                })
            },
            handleClick(row) {
                console.log(row);
            },
            page(currentPage) {
                this.currentPage.page = currentPage;
                this.getdata();
            },
            xaunding(row) {
                const valueId = this.valueId;
                if (valueId && valueId != 0) {

                    xaunding({valueId: valueId, pkId: row.pkId}).then(Object => {

                        this.$message({
                            type: '提示',
                            message: `选定成功`
                        });

                    })
                } else {
                    this.tooltip = true;
                }


            },

        },
        data() {
            return {
                tooltip: false,
                valueId: '',
                options: [],
                total: null,
                tableData: null,
                currentPage: {
                    page: 1,
                    total: 20,
                    count: 50,
                    current: 0,
                    limit: 10
                },
            }
        }
    }
</script>
